import { ExtraOptions, RouterModule, Routes } from '@angular/router';
import { NgModule } from '@angular/core';
import { NgxAuthComponent } from './auth/auth.component';
import {NgxLoginComponent} from "./auth/login/login.component";
import {NgxRegisterComponent} from "./auth/register/register.component";
import {NgxLogoutComponent} from "./auth/logout/logout.component";
import {NgxRequestPasswordComponent} from "./auth/request-password/request-password.component";
import {NgxResetPasswordComponent} from "./auth/reset-password/reset-password.component";

import { AuthGuard } from './auth/auth-guard';

const routes: Routes = [
  { path: 'pages',
    //canActivate: [AuthGuard],  // 这个是控制守卫，是用来做权限验证的，这个地方用了默认权限，所以暂时注释
    loadChildren: 'app/pages/pages.module#PagesModule' },
  {
    path: 'auth',
    component: NgxAuthComponent,
    children: [
      {
        path: '',
        component: NgxLoginComponent,
      },
      {
        path: 'login',
        component: NgxLoginComponent,
      },
      {
        path: 'register',
        component: NgxRegisterComponent,
      },
      {
        path: 'logout',
        component: NgxLogoutComponent,
      },
      {
        path: 'request-password',
        component: NgxRequestPasswordComponent,
      },
      {
        path: 'reset-password',
        component: NgxResetPasswordComponent,
      },]
  },
  { path: '',   redirectTo: 'pages', pathMatch: 'full' },
  { path: '**', redirectTo: 'pages' },
];

const config: ExtraOptions = {
  useHash: true,
};

@NgModule({
  imports: [RouterModule.forRoot(routes, config)],
  exports: [RouterModule],
})
export class AppRoutingModule {
}
